home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15358 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: === **ptr HELP ===
  5. Date: 18 Apr 1996 17:30:57 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4l5u8h$1sa@sparcserver.lrz-muenchen.de>
  9. References: <31765AA6.41C6@cell.co.uk>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. Kai Chan <kai@cell.co.uk> writes:
  13.  
  14. >Hi,
  15. >    I've got the following code fragment. Question I've got concerns
  16. >passing the pointer to a pointer to func1, and that is: which is
  17. >correct?
  18.  
  19. >blar...
  20. >blar...
  21.  
  22. >main()
  23. >{
  24. >    some_type1    **ptr;
  25.  
  26. "func1()" is defined as "func1(some_type1 **ptr)" in the article
  27.  
  28. >    func1(ptr);    /* is this right? */
  29.  
  30. You pass a "some_type1 **" to func1(), which is what the function 
  31. expects.
  32.  
  33. >    func1(&ptr);    /* or this? */
  34.  
  35. You pass a "some_type1 ***" to func1(), which is _not_ what the 
  36. function expects.
  37.  
  38. >    func1(**ptr);    /* or this? */
  39.  
  40. You pass a "some_type1" to func1(), which is _not_ what the 
  41. function expects.
  42.  
  43. >    func1(*ptr);    /* or this? */
  44.  
  45. You pass a "some_type1 *" to func1(), which is _not_ what the 
  46. function expects.
  47.  
  48. >    
  49. >}
  50.  
  51. Compilers are quite good at detecting type mismatch errors in calls 
  52. to functions, all you have to do is provide a prototype for func1()
  53. before you try to call it.
  54.  
  55. Kurt
  56. -- 
  57. | Kurt Watzka                             Phone : +49-89-2180-6254
  58. | watzka@stat.uni-muenchen.de
  59.